package base.day26.udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class SendDemo2 {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds=new DatagramSocket();

        String s="组播";
        byte[] bytes = s.getBytes();
        int port=10002;
        //要发送到的ip地址
        InetAddress address = InetAddress.getByName("224.0.1.0");

        DatagramPacket dp=new DatagramPacket(bytes,bytes.length,address,port);

        ds.send(dp);
        ds.close();
    }
}
